<?php require_once('Connections/connect.php'); ?>


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

mysql_select_db($database_connect, $connect);
$query_theloai = "SELECT machuyenmuc, tenchuyenmuc FROM chuyenmuc ORDER BY machuyenmuc ASC";
$theloai = mysql_query($query_theloai, $connect) or die(mysql_error());
$row_theloai = mysql_fetch_assoc($theloai);
$totalRows_theloai = mysql_num_rows($theloai);

$maxRows_tintrongloai = 5;
$pageNum_tintrongloai = 0;
if (isset($_GET['pageNum_tintrongloai'])) {
  $pageNum_tintrongloai = $_GET['pageNum_tintrongloai'];
}
$startRow_tintrongloai = $pageNum_tintrongloai * $maxRows_tintrongloai;

$colname_tintrongloai = "-1";
if (isset($_GET['machuyenmuc'])) {
  $colname_tintrongloai = $_GET['machuyenmuc'];
}
mysql_select_db($database_connect, $connect);
$query_tintrongloai = sprintf("SELECT * FROM baiviet WHERE machuyenmuc = %s ORDER BY ngayviet DESC", GetSQLValueString($colname_tintrongloai, "int"));
$query_limit_tintrongloai = sprintf("%s LIMIT %d, %d", $query_tintrongloai, $startRow_tintrongloai, $maxRows_tintrongloai);
$tintrongloai = mysql_query($query_limit_tintrongloai, $connect) or die(mysql_error());
$row_tintrongloai = mysql_fetch_assoc($tintrongloai);

if (isset($_GET['totalRows_tintrongloai'])) {
  $totalRows_tintrongloai = $_GET['totalRows_tintrongloai'];
} else {
  $all_tintrongloai = mysql_query($query_tintrongloai);
  $totalRows_tintrongloai = mysql_num_rows($all_tintrongloai);
}
$totalPages_tintrongloai = ceil($totalRows_tintrongloai/$maxRows_tintrongloai)-1;

mysql_select_db($database_connect, $connect);
$query_tinmoi = "SELECT * FROM baiviet ORDER BY ngayviet DESC";
$tinmoi = mysql_query($query_tinmoi, $connect) or die(mysql_error());
$row_tinmoi = mysql_fetch_assoc($tinmoi);
$totalRows_tinmoi = mysql_num_rows($tinmoi);

$queryString_tintrongloai = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_tintrongloai") == false && 
        stristr($param, "totalRows_tintrongloai") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_tintrongloai = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_tintrongloai = sprintf("&totalRows_tintrongloai=%d%s", $totalRows_tintrongloai, $queryString_tintrongloai);

$TFM_LimitLinksEndCount = 5;
$TFM_temp = $pageNum_tintrongloai + 1;
$TFM_startLink = max(1,$TFM_temp - intval($TFM_LimitLinksEndCount/2));
$TFM_temp = $TFM_startLink + $TFM_LimitLinksEndCount - 1;
$TFM_endLink = min($TFM_temp, $totalPages_tintrongloai + 1);
if($TFM_endLink != $TFM_temp) $TFM_startLink = max(1,$TFM_endLink - $TFM_LimitLinksEndCount + 1);

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="text.css" />
<link rel="stylesheet" href="styles.css" />
    <link rel="stylesheet" href="960.css" />
	

	<link rel="stylesheet" href="default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="pascal.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="orman.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
     <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
     <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
   <script type="text/javascript" src="jq/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="jq/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>

<title>HoroscopeVn</title>

</head>

<body>
<div class="white">
<div class="center">
<div class="clear"></div>
<div class="sliderr1">
<div class="sliderr">


        <div class="slider-wrapper theme-default">
            <div class="ribbon"></div>
            <div id="slider" class="nivoSlider">
                <img src="img/banner01.jpg" alt="" />
                <img src="img/banner02.jpg" alt="" />
                <img src="img/banner03.jpg" alt="" />
                <img src="img/banner05.jpg" alt="" />
				<img src="img/banner04.jpg" alt="" />
          </div>
            
       

    </div></div><div class="clear"></div>
</div>


<div class="menu">
<ul class="nav">
<li ><a href="index.php"><br />
TRANG CHỦ </a></li>
<?php do { ?>
  <li><a href="tintheoloai.php?machuyenmuc=<?php echo $row_theloai['machuyenmuc']; ?>"><br />
    <?php echo $row_theloai['tenchuyenmuc']; ?></a></li>
  <?php } while ($row_theloai = mysql_fetch_assoc($theloai)); ?>
<li ><a href="#"><br />
LIÊN HỆ </a></li>
</ul>
</div>

<div class="welcome">
<div class="visit">
<table width="600" border="0">
  <tr>
    <td width="207">
    <img src="img/<?php echo $row_tinmoi['anh']; ?>" width="190" height="180"> </td>
    <td width="383" valign="top"><table width="380" border="0">
      <tr valign="top">
      <td valign="top">
        <p><a href="chitiettin.php?mabaiviet=<?php echo $row_tinmoi['mabaiviet']; ?>" class="titletintheoloai">
		<?php echo $row_tinmoi['tenbaiviet']; ?></a> </p>
      <p class="text6">
          <?php echo $row_tinmoi['doantrich']; ?> </p>     </td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<div class="visitor"><? require("Login.php")?></div>
<img src="img/08.png" alt="img" />
</div><div class="clear"></div>


<div class="group">
<div class="experience">
<div class="tintheoloai"> 
<table width="550px" border=1px>
  <?php do { ?>
    <tr valign="top">
      <td bgcolor="#CDF1B1"> <p class="titletintheoloai"><a href="chitiettin.php?mabaiviet=<?php echo $row_tintrongloai['mabaiviet']; ?>"><?php echo $row_tintrongloai['tenbaiviet']; ?></a></p>
          <p><img src="img/<?php echo $row_tintrongloai['anh']; ?>" width="150" height="150" align="left"></p>
        <p></p>
        <p class="doantrich">&nbsp;</p>
        <p class="doantrich">&nbsp;</p>
        <p class="doantrich">&nbsp;</p>
        <p class="doantrich">&nbsp;</p>
        <p class="text9"><?php echo $row_tintrongloai['doantrich']; ?></p>        
        <p class="doantrich">&nbsp;</p></td>
    </tr>
    <?php } while ($row_tintrongloai = mysql_fetch_assoc($tintrongloai)); ?>
</table>
  <strong class="count">
  <?php
for ($i = $TFM_startLink; $i <= $TFM_endLink; $i++) {
  $TFM_LimitPageEndCount = $i -1;
  if($TFM_LimitPageEndCount != $pageNum_tintrongloai) {
    printf('<a href="'."%s?pageNum_tintrongloai=%d%s", $currentPage, $TFM_LimitPageEndCount, $queryString_tintrongloai.'">');
    echo "$i</a>";
  }else{
    echo "<strong>$i</strong>";
  }
if($i != $TFM_endLink) echo("--");}
?>
  </strong></div>
</div>

</div>
<div class="experience1"><img src="img/12.png" alt="img" /></div>


<div class="experience3">
<div class="tinxemnhieu"></div>
 </div>
</div>


<?php
mysql_free_result($tintrongloai);

mysql_free_result($tinmoi);

mysql_free_result($theloai);
?>

